/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MedicalDocumentation;

import EntityClass.Consent;
import EntityClass.Diagnosis;
import EntityClass.Finding;
import EntityClass.Medical_Procedure;
import EntityClass.mCase;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Ashish
 */
@Stateless
public class DecisionMakingandPlaning {

  @PersistenceContext()
    EntityManager em;

    public void AddPlanedTask(Long CIN, Diagnosis diagnosis, Finding finding, Consent consent) {
        
        mCase mcase = em.find(mCase.class, CIN);
        
        Medical_Procedure procedure = this.createProc(mcase, diagnosis, finding, consent);
        
        mcase.addmedicaProcedure(procedure);
        
        System.out.println("Medical Procedure " + procedure.getId() + 
                "added to case " + mcase.getCIN());
        
        em.persist(mcase);
        
    }
    
    public void GetConsent(Long procedureId, String patient_comment) {
        Medical_Procedure procedure = em.find(Medical_Procedure.class, procedureId);
        
        Consent consent = new Consent();
        consent.create(patient_comment);
        
        procedure.setConsent(consent);        
        
    }
    
    public List<Medical_Procedure> RetrieveCarePlaning (Long PIN){
        List<Medical_Procedure> procedures;
        
        mCase mcase = em.find(mCase.class, PIN);
        
        procedures = mcase.getmProcedures();
        
       return procedures;
    }
    
    public void RetrieveMedicalKnowledge(){
    }
    
    public Medical_Procedure createProc (mCase mcase, Diagnosis diagnosis, Finding finding, Consent consent){
        Medical_Procedure mproc = new Medical_Procedure();
        mproc.create(consent, diagnosis, mcase, finding);
        
       return mproc;
    }

}
